package com.kuang.controller;

import com.kuang.mapper.EmployeeMapper;
import com.kuang.pojo.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class EmployeeController {
    @Autowired
    private EmployeeMapper employeeMapper;

    @RequestMapping("/getEmployees")
    public List<Employee> getEmployees(){
        return employeeMapper.getEmployees();
    }
    @RequestMapping("/save")
    public int save(){
        Employee employee = new Employee();
        employee.setLastName("林福生");
        employee.setEmail("linfusheng@qq.com");
        employee.setGender(1);
        employee.setDepartment(109);
        employee.setBirth(new Date());
        return employeeMapper.save(employee);

    }
    @RequestMapping("/get/{id}")
    public Employee get(@PathVariable("id") Integer id){
        return employeeMapper.get(id);
    }
    @RequestMapping("/delete/{id}")
    public int delete(@PathVariable("id") Integer id){
        return employeeMapper.delete(id);
    }


}
